<!DOCTYPE HTML>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
		<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
		<link rel="stylesheet" type="text/css" href="../../css/style.css" />
		<style type="text/css">
			html,body {
				height:100%;
				background-color:#F7F8FA;
				/*overflow-y: auto;
				-webkit-overflow-scrolling:touch;*/
			}

			.vehicle_time{ background-color:#fff; padding: 5px 15px 15px;}
			.vehicle_time b{ display:block; font-size: 15px; color: #333; font-weight: 500; line-height: 35px;}
			.vehicle_time p{ position: relative; font-size: 15px; color: #333; line-height: 30px; padding-left: 25px;}
			.vehicle_time p:first-child{ margin-bottom: 6px;}
			.vehicle_time p img{ position: absolute; left: 0; top: 50%; margin-top: -9px; width: 18px; height: 18px; line-height: 18px; text-align: center; font-size: 10px; color: #fff; background-color: #3bcb9f; border-radius: 50%;}
			.vehicle_time p em{ position:absolute; left: 8px; top: 28px; border-right: 1px #e0e0e0 solid; height: 10px;}
			.vehicle_time b span{float:right;font-size:12px;color:#3262F1;font-weight:normal;}
			
			.vehicle_info{ background-color: #fff; padding: 10px 15px 0; overflow: hidden;}
			.vehicle_info li{ height: 50px; font-size: 15px; color: #202532; line-height: 50px; position: relative;}
			.vehicle_info li::after{ position:absolute; content: ""; left: 0; right: -10px; bottom: 0; border-bottom: 1px #f0f1f3 solid; transform: scaleY(0.5);}
			.vehicle_info b{ float:left; font-size: 16px; font-weight: 400;}
			.vehicle_info p{ float:right; font-size:14px; color:#333;}
			.vehicle_time01{ padding-top:15px; }
			
			.identit_info{ padding: 50px 15px 42px; background-color: #fff;}
			.identit_info b{ display:block; font-size: 14px; color: #403D3D; font-weight: 500; line-height: 50px;}
			.identit_info li{ float: left; width: 48.5%; overflow: hidden; margin-bottom: 10px; background-color:#f9f9f9;}
			.identit_info li:nth-child(2n){ float: right;}
			.identit_info img{ width: 100%; border-radius: 4px; height:106px; object-fit: cover;}
			.identit_info .loadimg { width:16px; height:16px; margin:45px auto; vertical-align: middle;}
			.identit_info01{ margin-top: 10px; padding-top: 0; padding-bottom: 10px;}
			
			.vehicle_state{ position: relative; padding: 15px 15px 0;  color: #fff;background-color: #F7F8FA;}
			
			.vehicle_state .m_cell_hd img{ width: 36px; margin-right: 10px;}
			.vehicle_state .m_cell_hd h4{ display:block; font-size: 15px; line-height: 20px;}
			.vehicle_state .m_cell_hd p{ font-size: 12px; opacity: 0.7; line-height: 20px;}
			.vehicle_state .info{ margin-bottom: 15px; padding: 10px 0 10px; background-color: #fff; border-radius: 4px; box-shadow: 0 0 10px rgba(0,0,0,0.07); min-height: 60px;}
			
			.vehicle_state .info b{ display: block; padding: 0 15px; font-size: 15px; color: #333; line-height: 35px;}
			.vehicle_state .info i{ color:#3bcb9f;}
			.vehicle_state .info i.on{ color:#333;}
			
			.vehicle_state .info .baoxian_list{ width: 100%; font-size: 14px; color: #333; text-align: center; padding-bottom: 10px;}
			.vehicle_state .info .baoxian_list li{ line-height: 35px; height: 35px; overflow: hidden;}
			.vehicle_state .info .baoxian_list div{ float: left; width: 33.33%; text-align: center; overflow: hidden; height: 35px;}
			.vehicle_state .info .baoxian_list li:nth-child(1){ font-size:12px; color: #9F9F9F; }
			
			.vehicle_state02 .info .baoxian_list li,.vehicle_state06 .info .baoxian_list li{ position: relative; line-height: 35px; height: 35px; overflow: hidden;}
			.vehicle_state02 .info .baoxian_list div,.vehicle_state06 .info .baoxian_list div{ float: left; width: 33.33%; text-align: center; overflow: hidden; height: 35px;}
			.vehicle_state02 .info .baoxian_list li:nth-child(1),.vehicle_state06 .info .baoxian_list li:nth-child(1){ font-size:12px; color: #9F9F9F; }
			.vehicle_state02 .info .baoxian_list li:nth-last-child(2),.vehicle_state06 .info .baoxian_list li:nth-last-child(2){ height: 48px; line-height:40px; }
			.vehicle_state02 .info .baoxian_list li:nth-last-child(2)::after{ display:block; position: absolute; content: ""; left: 15px; right: 15px; bottom: 0; height: 1px; background-color: #ededed; -webkit-transform: scaleY(0.5); transform: scaleY(0.5);}
			.vehicle_state02 .info .baoxian_list li:last-child{ font-size:15px; padding:0 15px; line-height: 45px; }
			.vehicle_state06 .info .baoxian_list li:nth-last-child(2)::after{ display:block; position: absolute; content: ""; left: 15px; right: 15px; bottom: 0; height: 1px; background-color: #ededed; -webkit-transform: scaleY(0.5); transform: scaleY(0.5);}
			.vehicle_state06 .info .baoxian_list li:last-child{ font-size:15px; padding:0 15px; line-height: 45px; }
			
			.vehicle_state04{ background: url(../../image/insurebg1.png) no-repeat 0 0; background-size: 100% 80px; position: relative; padding: 22px 15px 18px;  color: #fff;background-color: #fff;}
			.vehicle_state06{ background: url(../../image/insurebg2.png) no-repeat 0 0; background-size: 100% 160px; position: relative; padding: 22px 15px 0;  color: #fff;background-color: #fff;}
			.color333{color:#333;}
			.pcolor333{color:#333; opacity:0.67;}
			
			.add_input{ margin-top: 10px; background-color: #fff; line-height:48px; padding: 0 15px;}
			.add_input li{ position:relative;}
			.add_input li:not(:last-child)::after{ position: absolute; content: ""; left: 0; bottom: 0; right: -10px; border-top: 1px #d5d5d5 solid; transform: scaleY(0.5);}
			.add_input b{ display:block; font-size: 15px; font-weight: 400; color: #333;}
			.add_input input{ display:block; border: 0; width: 100%; box-sizing: border-box; text-align: right; font-size: 14px; color: #333; padding: 12px 0;}
			.add_input input.on{ padding-right: 15px; background: url(../../image/img_13.png) no-repeat right center; background-size: 6px auto;}
			
			.upload_img input{ position:absolute; right: 0; top: 0; bottom: 0; width: 100%; opacity: 0; z-index: 2;}
			
			.upload{ margin-top: 10px; padding: 0 15px 10px; background-color: #fff;}
			.upload li{ float:left; width: 70px; position: relative; margin-right: 4%; margin-bottom: 2%;}
			.upload li:nth-child(4n+4){ margin-right: 0;}
			.upload a{ display:block; position: relative; overflow: hidden;}
			.upload img{ width: 70px; height:70px; border-radius: 3px; object-fit: cover;}
			.upload input{ position:absolute; right: 0; top: 0; bottom: 0; opacity: 0;}
			.upload em{ position:absolute; right: -8px; top: -8px; width: 17px; height: 17px; border-radius: 50%; background: url(../../image/img_33.png); background-size: 100% auto;}
			.add_btn{ padding: 45px 15px;}
			
			.upload_img{ margin-top: 10px; padding: 0 15px; background-color: #fff; overflow: hidden;}
			.upload_img b{ display:block; position: relative; margin-bottom: 2px; font-size: 15px; color: #333; font-weight: 400; line-height: 50px; }
			.upload_img b div{ position: absolute; right: 0; top: 0; font-size: 13px; color: #333; line-height: 50px; height: 50px;}
			.upload_img b div span,.add_input .m_cell_ft span{ float:left; margin-left: 20px; padding-left: 18px; background: url(../../image/img_24.png) no-repeat 0 18px; line-height: 50px; background-size: 13px auto;}
			.upload_img b div span.on,.add_input .m_cell_ft span.on{ background-image: url(../../image/img_25.png);}
			.upload_img ul{ padding-bottom: 10px;}
			.upload_img li{ float:left; width: 48.5%; height:106px; border: 0.5px #9F9F9F solid; border-radius: 6px; margin-bottom:10px; overflow: hidden; position: relative;}
			.upload_img li:nth-child(2n){ float: right;}
			.upload_img2 .img{ width: 100%; border-radius: 4px;}
			.upload_img .img{ display:none; width: 100%; height:200px; object-fit: cover;}
			.upload_img li.on{ border:0;}
			.upload_img li.on i{ display:block;}
			.upload_img li.on div{ display:none;}
			.upload_img li.on .img{ display:block;}
			.upload_img i{ display:none; position:absolute; right: 10px; top: 10px; width: 20px; height: 20px; border-radius: 50%; background-image: url(../../image/img_33.png); background-size: 100% auto; z-index: 3;}
			
			.upload_img li div{ position:absolute; left: 0; top: 50%; right: 0; transform: translateY(-50%); text-align: center; font-size: 12px; color: #999;}
			.upload_img li div img{ margin:0 auto; width: 25px; }
			.upload_img li p{ padding-top: 5px;}
			.btn { padding:15px; }
			/*上传资料*/
			.add_input .m_cell_ft span{ float:right; font-size: 13px; line-height: 42px; background-position: 0 14px;}
			.grlb{ padding: 10px 15px 0;}
			.grlb p{ color: #333; line-height: 30px; height: 30px; position: relative; padding-left: 18px; font-size: 12px;}
			.grlb a{ display:inline; color: #1c63fa;}
			.grlb em{ position: absolute; left: 0; top: 8px; width: 13px; height: 13px; border-radius: 50%; background-image: url(../../image/img_24.png); background-size: 100% auto;}
			.grlb em.on{ background-image: url(../../image/img_25.png);}
			.d_btn span { opacity:0.49; } 
			.display-none{ display:none; }
			
			
			.mt10 { margin-top:10px; }
			.mt30 { margin-top:30px; }
			.sk-three-bounce {
			  margin: 0 auto;
			  width: 80px;
			  text-align: center; }
			  .sk-three-bounce .sk-child {
				width: 13.5px;
				height: 13.5px;
				background-color: #3262F1;
				border-radius: 100%;
				display: inline-block;
				-webkit-animation: sk-three-bounce 1.4s ease-in-out 0s infinite both;
						animation: sk-three-bounce 1.4s ease-in-out 0s infinite both; }
			  .sk-three-bounce .sk-bounce1 {
				-webkit-animation-delay: -0.32s;
						animation-delay: -0.32s; }
			  .sk-three-bounce .sk-bounce2 {
				-webkit-animation-delay: -0.16s;
						animation-delay: -0.16s; }

			@-webkit-keyframes sk-three-bounce {
			  0%, 80%, 100% {
				-webkit-transform: scale(0);
						transform: scale(0); }
			  40% {
				-webkit-transform: scale(1);
						transform: scale(1); } }

			@keyframes sk-three-bounce {
			  0%, 80%, 100% {
				-webkit-transform: scale(0);
						transform: scale(0); }
			  40% {
				-webkit-transform: scale(1);
						transform: scale(1); }
			}
		</style>
	</head>
	<body>
		<div id="insuredetail">
		</div>
		<script id="insuredetail_template" type="text/template">
		<div class="vehicle_state{{? it.status > 1 && it.status != 4 && it.status != 6}} vehicle_state02{{??}} vehicle_state0{{=it.status}}{{?}}">
			<div class="info">
				<b>联保单</b>
				<div class="baoxian_list">
					<ul>
						<li>
							<div>联保险种</div>
							<div>联保金额</div>
							<div>联保费用</div>
						</li>
						<li>
							<div>三者损失</div>
							<div><i class="on">{{=it.threebaofee}}万元</i></div>
							<div>{{? it.threexianfee == 0}}<i>评估中</i>{{??}}{{=it.threexianfee}}元{{?}}</div>
						</li>
						{{? it.jdcxian == 1}}
						<li>
							<div>机动车损失</div>
							<div>{{? it.jdcbaofee == 0}}<i>评估中</i>{{??}}{{=it.jdcbaofee}}万元{{?}}</div>
							<div>{{? it.jdcxianfee == 0}}<i>评估中</i>{{??}}{{=it.jdcxianfee}}元{{?}}</div>
						</li>
						{{?}}
						{{? it.zrxian == 1}}
						<li>
							<div>自燃损失</div>
							<div>{{? it.zrbaofee == 0}}<i>评估中</i>{{??}}{{=it.zrbaofee}}万元{{?}}</div>
							<div>{{? it.zrxianfee == 0}}<i>评估中</i>{{??}}{{=it.zrxianfee}}元{{?}}</div>
						</li>
						{{?}}
						{{? it.dqxian == 1}}
						<li>
							<div>盗抢损失</div>
							<div>{{? it.dqbaofee == 0}}<i>评估中</i>{{??}}{{=it.dqbaofee}}万元{{?}}</div>
							<div>{{? it.dqxianfee == 0}}<i>评估中</i>{{??}}{{=it.dqxianfee}}元{{?}}</div>
						</li>
						{{?}}
						{{? it.jsyxian == 1}}
						<li>
							<div>驾驶员损失</div>
							<div>{{? it.jsybaofee == 0}}<i>评估中</i>{{??}}{{=it.jsybaofee}}万元{{?}}</div>
							<div>{{? it.jsyxianfee == 0}}<i>评估中</i>{{??}}{{=it.jsyxianfee}}元{{?}}</div>
						</li>
						{{?}}
						{{? it.ckxian == 1}}
						<li>
							<div>乘客保障</div>
							<div>{{? it.ckbaofee == 0}}<i>评估中</i>{{??}}{{=it.ckbaofee}}万元{{?}}</div>
							<div>{{? it.ckxianfee == 0}}<i>评估中</i>{{??}}{{=it.ckxianfee}}元{{?}}</div>
						</li>
						{{?}}
						{{? it.hwxian == 1}}
						<li>
							<div>货物损失</div>
							<div>{{? it.hwbaofee == 0}}<i>评估中</i>{{??}}{{=it.hwbaofee}}万元{{?}}</div>
							<div>{{? it.hwxianfee == 0}}<i>评估中</i>{{??}}{{=it.hwxianfee}}元{{?}}</div>
						</li>
						{{?}}
						{{? it.status > 1}}
						<li>
							<div style="text-align:left;">合计</div>
							<div>&nbsp;</div>
							<div style="text-align:right;font-size:20px;font-weight:500;">¥{{=it.allxianfee}}</div>
						</li>
						{{?}}
					</ul>
				</div>
			</div>
		</div>
		
		<div class="vehicle_time vehicle_time01">
			<b>联保有效期</b>
			<ul>
				<p><em></em><img src="../../image/img_38.png" alt="" />{{=it.insurestarttime}}</p>
				<p><img src="../../image/img_39.png" alt="" />{{=it.insureendtime}}</p>
			</ul>
		</div>
		<div class="add_input">
			<ul>
				{{? it.usertype == 1}}
				<li>
					<div class="m_cell_hd"><b>受益人</b></div>
					<div class="m_cell_ft m_cell_primary"><input type="text" id="beneficiary" value="" placeholder="受益人姓名" /></div>
				</li>
				<li class="display-none">
					<div class="m_cell_hd"><b>企业法人</b></div>
					<div class="m_cell_ft m_cell_primary"><input type="text" id="realname" value="" placeholder="法人姓名" /></div>
				</li>
				<li>
					<div class="m_cell_hd"><b>身份证号</b></div>
					<div class="m_cell_ft m_cell_primary"><input type="text" id="idcard" value="" placeholder="受益人身份证号" /></div>
				</li>
				{{??}}
				<li>
					<div class="m_cell_hd"><b>受益人</b></div>
					<div class="m_cell_ft m_cell_primary"><input type="text" id="beneficiary" value="" placeholder="企业名称" /></div>
				</li>
				<li>
					<div class="m_cell_hd"><b>企业法人</b></div>
					<div class="m_cell_ft m_cell_primary"><input type="text" id="realname" value="" placeholder="法人姓名" /></div>
				</li>
				<li>
					<div class="m_cell_hd"><b>身份证号</b></div>
					<div class="m_cell_ft m_cell_primary"><input type="text" id="idcard" value="" placeholder="法人身份证号" /></div>
				</li>
				{{?}}
				<li>
					<div class="m_cell_hd"><b>车牌号</b></div>
					<div class="m_cell_ft m_cell_primary" tapmode onclick="selCarnum();"><input type="text" id="carnum" value="" placeholder="例：川A·12321" readonly /></div>
				</li>
				<li>
					<div class="m_cell_hd"><b>车辆类型</b></div>
					<div class="m_cell_ft m_cell_primary" id="cartypelist">
						<span tapmode data-cartype="2" onclick="selCartype(this);">旧车</span>
						<span tapmode data-cartype="1" onclick="selCartype(this);" class="on">新车</span>
					</div>
				</li>
			</ul>
		</div>

		<div class="upload_img">
			<b id="picnamediv">{{? it.usertype == 1}}受益人身份证照片（正反面）{{??}}法人身份证照片（正反面）{{?}}</b>
			<ul class="clearfix">
				<li tapmode onclick="selpic(1);">
					<i tapmode onclick="delimg(this,1);"></i>
					<div> 
						<img src="../../image/img_32.png" alt="" />
						<p>上传正面照</p>
					</div>
					<img src="../../image/kong.png" id="cardIDthumb1" class="img"/>
					<input type="hidden" name="cardIDthumb_1" id="cardIDthumb_1" value="" />
				</li>
				<li tapmode onclick="selpic(2);">
					<i tapmode onclick="delimg(this,2);"></i>
					<div>
						<img src="../../image/img_32.png" alt="" />
						<p>上传反面照</p>
					</div>
					<img src="../../image/kong.png" id="cardIDthumb2" class="img"/>
					<input type="hidden" name="cardIDthumb_2" id="cardIDthumb_2" value="" />
				</li>
			</ul>
		</div>
		<div class="upload_img display-none" id="companypicdiv">
			<b>营业执照</b>
			<ul class="clearfix">
				<li tapmode onclick="selpic(3);">
					<i tapmode onclick="delimg(this,3);"></i>
					<div>
						<img src="../../image/img_32.png" alt="" />
					</div>
					<img src="../../image/kong.png" id="cardIDthumb3" class="img"/>
					<input type="hidden" name="cardIDthumb_3" id="cardIDthumb_3" value="" />
				</li>
			</ul>
		</div>
		<div class="upload_img">
			<b>车辆强制保险保单照片</b>
			<ul class="clearfix">
				<li tapmode onclick="selpic(4);">
					<i tapmode onclick="delimg(this,4);"></i>
					<div>
						<img src="../../image/img_32.png" alt="" />
					</div>
					<img src="../../image/kong.png" id="cardIDthumb4" class="img"/>
					<input type="hidden" name="cardIDthumb_4" id="cardIDthumb_4" value="" />
				</li>
			</ul>
		</div>

		<div class="upload_img">
			<b>车辆商业保险保单照片
			<div id="havepictypelist">
				<span tapmode onclick="selPictype(this,1);" class="on">有</span>
				<span tapmode onclick="selPictype(this,0);">无</span>
			</div>
			</b>
			<ul class="clearfix" id="picarea">
				<li tapmode onclick="selpic(5);">
					<i tapmode onclick="delimg(this,5);"></i>
					<div>
						<img src="../../image/img_32.png" alt="" />
					</div>
					<img src="../../image/kong.png" id="cardIDthumb5" class="img"/>
					<input type="hidden" name="cardIDthumb_5" id="cardIDthumb_5" value="" />
				</li>
			</ul>
		</div>

		<div class="upload_img">
			<b>车辆行驶证照片（正副本）</b>
			<ul class="clearfix">
				<li tapmode onclick="selpic(6);">
					<i tapmode onclick="delimg(this,6);"></i>
					<div>
						<img src="../../image/img_32.png" alt="" />
						<p>正本照片</p>
					</div>
					<img src="../../image/kong.png" id="cardIDthumb6" class="img"/>
					<input type="hidden" name="cardIDthumb_6" id="cardIDthumb_6" value="" />
				</li>
				<li tapmode onclick="selpic(7);">
					<i tapmode onclick="delimg(this,7);"></i>
					<div>
						<img src="../../image/img_32.png" alt="" />
						<p>副本照片</p>
					</div>
					<img src="../../image/kong.png" id="cardIDthumb7" class="img"/>
					<input type="hidden" name="cardIDthumb_7" id="cardIDthumb_7" value="" />
				</li>
			</ul>
		</div>
		
		<div class="upload_img">
			<b>车辆照片</b>
			<ul class="clearfix">
				<li tapmode onclick="selpic(8);">
					<i tapmode onclick="delimg(this,8);"></i>
					<div>
						<img src="../../image/img_32.png" alt="" />
						<p>车辆左45度照</p>
					</div>
					<img src="../../image/kong.png" id="cardIDthumb8" class="img"/>
					<input type="hidden" name="cardIDthumb_8" id="cardIDthumb_8" value="" />
				</li>
				<li tapmode onclick="selpic(9);">
					<i tapmode onclick="delimg(this,9);"></i>
					<div>
						<img src="../../image/img_32.png" alt="" />
						<p>车辆右45度照</p>
					</div>
					<img src="../../image/kong.png" id="cardIDthumb9" class="img"/>
					<input type="hidden" name="cardIDthumb_9" id="cardIDthumb_9" value="" />
				</li>
				<li tapmode onclick="selpic(10);">
					<i tapmode onclick="delimg(this,10);"></i>
					<div>
						<img src="../../image/img_32.png" alt="" />
						<p>车辆后方照</p>
					</div>
					<img src="../../image/kong.png" id="cardIDthumb10" class="img"/>
					<input type="hidden" name="cardIDthumb_10" id="cardIDthumb_10" value="" />
				</li>
			</ul>
		</div>

		<div class="f_line"></div>
		<div class="btn">
			<button class="d_btn" tapmode="btnpress" onclick="addinsure();" id="login-btn"><span>确认变更</span></button>
		</div>
		</script>
	</body>
	<script type="text/javascript" src="../../script/api.js" ></script>
	<script type="text/javascript" src="../../script/app.js" ></script>
	<script type="text/javascript" src="../../script/doT.js"></script>
	<script type="text/javascript">
		var uid;
		var usertype;
		var insureid;
		var cartype = 1;
		var pictype = 1;
		var licencePlatekeyboard;
		var curImgId = 0;
		var UILoading;
		apiready = function() {
			api.parseTapmode();
			UILoading = api.require('UILoading');
			licencePlatekeyboard = api.require('licencePlatekeyboard');
			
			showloading();
			uid = api.pageParam.uid;
			insureid = api.pageParam.insureid;
			getJsonFromAPI();
			api.addEventListener({
                name: 'navitembtn'
            }, function(ret, err) {
                if (ret.type == 'left') {
					api.closeWin({
					});
                }
            });
		}
		function getJsonFromAPI() {
			//从接口获取查询数据
			api.getPrefs({
				key: 'user_info'
			}, function(ret, err) {
				if (ret.value) {
					var userinfo = JSON.parse(ret.value);
					api.ajax({
						url: ApiUrl + '/v1/insuredetail/'+insureid,
						method: 'get',
						cache: false,
						timeout: 10,
						headers: {
							authorization: kAppKey+';'+userinfo.access_token+';'+userinfo.uid
						}
					}, function(ret, err) {
						hideloading();
						if (ret) {
							console.log(JSON.stringify(ret.insure));
							var insuredetail = ret.insure;
							usertype = insuredetail.usertype;
							UpdateList('insuredetail','insuredetail_template',insuredetail);
							

						} else {
							if(err.statusCode==402)
							{
								Relogin();
							}
							else
							{
								toast('网络异常');
								console.log(JSON.stringify(err));
							}
						}
					});
				}
			});
		}
		//渲染数据
		function UpdateList(domId,templateId,jsondata) {
			var act_content = $api.byId(domId);
			var tempFn = doT.template($api.byId(templateId).innerHTML);
			var resultText = tempFn(jsondata);
			$api.html(act_content, resultText);
			api.parseTapmode();
			
			
		}
		function addinsure() {
			document.activeElement.blur();
			var beneficiary = $api.val($api.byId('beneficiary')).trim();
			var realname = $api.val($api.byId('realname')).trim();
			var cardID = $api.val($api.byId('idcard')).trim();
			var carnum = $api.val($api.byId('carnum')).trim();
			var cardIDthumb1 = $api.val($api.byId('cardIDthumb_1')).trim();
			var cardIDthumb2 = $api.val($api.byId('cardIDthumb_2')).trim();
			var cardIDthumb3 = $api.val($api.byId('cardIDthumb_3')).trim();
			var cardIDthumb4 = $api.val($api.byId('cardIDthumb_4')).trim();
			var cardIDthumb5 = $api.val($api.byId('cardIDthumb_5')).trim();
			var cardIDthumb6 = $api.val($api.byId('cardIDthumb_6')).trim();
			var cardIDthumb7 = $api.val($api.byId('cardIDthumb_7')).trim();
			var cardIDthumb8 = $api.val($api.byId('cardIDthumb_8')).trim();
			var cardIDthumb9 = $api.val($api.byId('cardIDthumb_9')).trim();
			var cardIDthumb10 = $api.val($api.byId('cardIDthumb_10')).trim();
			
			var tsname = '受益人姓名';
			var tsn = '受益人';
			if(usertype == 2)
			{
				tsname = '企业名称';
				tsn = '法人';
			}
			
			if($api.cssVal($api.byId('login-btn'),'opacity')!=1)
			{
				return false;
			}
			if(beneficiary == '')
			{
				showtoast("warning","请填写"+tsname);
				return false;
			}
			if(usertype == 2 && realname == '')
			{
				showtoast("warning","请填写"+tsn+"姓名");
				return false;
			}
			if(cardID == '')
			{
				showtoast("warning","请填写"+tsn+"身份证");
				return false;
			}
			if(!IdentityCodeValid(cardID))
			{
				showtoast("warning","请填写真实身份证号");
				return false;
			}
			if(carnum == '')
			{
				showtoast("warning","请填写车牌号");
				return false;
			}
			if(cardIDthumb1=="")
			{
				showtoast("warning","请上传身份证正面照");
				return false;
			}
			if(cardIDthumb2=="")
			{
				showtoast("warning","请上传身份证背面照");
				return false;
			}
			if(usertype == 2 && cardIDthumb3=="")
			{
				showtoast("warning","请上传营业执照");
				return false;
			}
			if(cardIDthumb4=="")
			{
				showtoast("warning","请上传强制保单图片");
				return false;
			}
			if(pictype == 1)
			{
				if(cardIDthumb5=="")
				{
					showtoast("warning","请上传商业保单图片");
					return false;
				}
			}
			if(cardIDthumb6=="")
			{
				showtoast("warning","请上传行驶证正本");
				return false;
			}
			if(cardIDthumb7=="")
			{
				showtoast("warning","请上传行驶证副本");
				return false;
			}
			if(cardIDthumb8=="")
			{
				showtoast("warning","请上传车辆左45°照");
				return false;
			}
			if(cardIDthumb9=="")
			{
				showtoast("warning","请上传车辆右45°照");
				return false;
			}
			if(cardIDthumb10=="")
			{
				showtoast("warning","请上传车辆后方照");
				return false;
			}
			showbtnloading('login-btn');
			
			var paramsObj = {
				beneficiary: beneficiary,
				realname: realname,
				cardID: cardID,
				carnum: carnum,
				cartype: cartype,
				cardIDthumb1: cardIDthumb1,
				cardIDthumb2: cardIDthumb2,
				cardIDthumb3: cardIDthumb3,
				cardIDthumb4: cardIDthumb4,
				cardIDthumb5: cardIDthumb5,
				cardIDthumb6: cardIDthumb6,
				cardIDthumb7: cardIDthumb7,
				cardIDthumb8: cardIDthumb8,
				cardIDthumb9: cardIDthumb9,
				cardIDthumb10: cardIDthumb10,
				step: 3,
				oldinsureid: insureid,
				uid: uid
			}
			api.getPrefs({
				key: 'user_info'
			}, function(ret, err) {
				if (ret && ret.value)
				{
					var userinfo = JSON.parse(ret.value);
					api.ajax({
						url: ApiUrl + '/v1/insure',
						method: 'post',
						cache: false,
						timeout: 10,
						headers: {
							authorization: kAppKey+';'+userinfo.access_token+';'+userinfo.uid
						},
						data: {
							values: paramsObj
						}
					}, function(ret, err) {
						if (ret) {
							openAlert();
						} else {
							console.log(JSON.stringify(err));
							showtoast("warning",err.body.error);
						}
						hidebtnloading('login-btn','确认变更');
					});
				}
			});
		}
		function isLicenseNo(str) {
			//检验车牌号
			return /(^[\u4E00-\u9FA5]{1}[A-Z0-9]{6}$)|(^[A-Z]{2}[A-Z0-9]{2}[A-Z0-9\u4E00-\u9FA5]{1}[A-Z0-9]{4}$)|(^[\u4E00-\u9FA5]{1}[A-Z0-9]{5}[挂学警军港澳]{1}$)|(^[A-Z]{2}[0-9]{5}$)|(^(08|38){1}[A-Z0-9]{4}[A-Z0-9挂学警军港澳]{1}$)/.test(str);
		}
		function agreenterm(obj) {
			$api.toggleCls(obj.firstElementChild,'on');
		}
		function funcChina(str){ 
			if(/.*[\u4e00-\u9fa5]+.*$/.test(str)) 
			{ 
				//alert("不能含有汉字！"); 
				return false; 
			} 
			return true; 
		}
		function selCarnum() {
			document.activeElement.blur();
			//选择车牌号
			licencePlatekeyboard.open(function(ret) {
				if(ret.clickListener != '删除')
				{
					var carnum = $api.val($api.byId('carnum'));
					carnum += '' + ret.clickListener;
					
					if(!funcChina(ret.clickListener))
					{
						carnum = ret.clickListener;
					}
					$api.val($api.byId('carnum'),carnum);
					if(carnum.length == 7)
					{
						licencePlatekeyboard.close();
					}
				}
				else
				{
					var carnum = $api.val($api.byId('carnum'));
					carnum = carnum.substring(0,carnum.length-1);
					$api.val($api.byId('carnum'),carnum);
				}
				//alert(JSON.stringify(ret));
			});
		}
		function selCartype(obj) {
			document.activeElement.blur();
			cartype = $api.attr(obj,'data-cartype');
			var liList = document.getElementById("cartypelist").children;
			for (var i = 0; i < liList.length; i++) {
				$api.removeCls(liList[i], 'on')
			}
			$api.addCls(obj,'on');
			
		}
		function selPictype(obj,typeid) {
			document.activeElement.blur();
			var liList = document.getElementById("havepictypelist").children;
			for (var i = 0; i < liList.length; i++) {
				$api.removeCls(liList[i], 'on')
			}
			$api.addCls(obj,'on');
			if(typeid == 1)
			{
				pictype = 1;
				$api.css($api.byId('picarea'),'display:block');
			}
			else
			{
				pictype = 0;
				$api.css($api.byId('picarea'),'display:none');
			}
		}
		function delimg(obj,id) {
			//清楚已选图片
			event.stopPropagation();
			$api.removeCls(obj.parentNode,'on');
			$api.val($api.byId('cardIDthumb_'+id),'');
			$api.byId('cardIDthumb'+id).src = '../../image/kong.png';
		}
		function selpic(id) {
			
			api.actionSheet({
				cancelTitle: '取消',
				buttons: ['拍照', '从手机相册选择'],
				style: {
					layerColor:'rgba(0,0,0,0.3)',         //遮蔽层颜色，仅支持 rgba颜色，默认值：rgba（0, 0, 0, 0.4）
					itemNormalColor:'#fff',    //选项按钮正常状态背景颜色，支持#000、#000000、rgb、rgba，默认值：#F1F1F1
					itemPressColor:'#f5f5f5',     //选项按钮按下时背景颜色，支持#000、#000000、rgb、rgba，默认值：#E6E6E6
					fontNormalColor:'#333',    //选项按钮正常状态文字颜色，支持#000、#000000、rgb、rgba，默认值：#007AFF
					fontPressColor:'#000',     //选项按钮按下时文字颜色，支持#000、#000000、rgb、rgba，默认值：#0060F0
					titleFontColor:'#000'      //标题文字颜色，支持#000、#000000、rgb、rgba，默认值：#8F8F8F
				}
			}, function(ret, err) {
				if(ret.buttonIndex==1 || ret.buttonIndex==2)
				{
					getPicture(ret.buttonIndex,id);
				}
			});
		}
		function openAlbum() {
			getPicture(2,curImgId);
		}
		function openCamera() {
			getPicture(1,curImgId);
		}
		function getPicture(index,id){
			curImgId = id;
			var perdesc = '相册/本地存储';
			var sourceType = 'library';
			var callbakstr = openAlbum;
            if(index==1){
				var pername = new Array('storage','camera');
				sourceType = 'camera';
				perdesc = '相册/拍照';
				callbakstr = openCamera;
				
				if (api.systemType == "android") {
					if(!confirmPerarr(pername,perdesc,callbakstr)){
						return;
					}
				}
			}
			else
			{
				var pername = 'photos';
				if (api.systemType == "android") {
					if(pername == 'photos')
					{
						pername = 'storage';
					}
					if(!confirmPer(pername,perdesc,callbakstr)){
						return;
					}
				}
			}
			api.getPicture({
				sourceType: sourceType,
				encodingType: 'png',
				mediaValue: 'pic',
				targetWidth: 600,
			}, function(ret, err) {
			// 获取图片数据并处理
				if (ret) {
					var imgSrc = ret.data;
					if (imgSrc != "") {
						uploadImage(imgSrc,id);
					}
				}
			});
		}
		function uploadImage(item,id)
		{
			var imageCachePath = api.cacheDir;
			var picname = randomString(32);
			imgFilter(item,id);
		}
		function randomString(len) {
		　　len = len || 32;
		　　var $chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678';    /****默认去掉了容易混淆的字符oOLl,9gq,Vv,Uu,I1****/
		　　var maxPos = $chars.length;
		　　var pwd = '';
		　　for (i = 0; i < len; i++) {
		　　　　pwd += $chars.charAt(Math.floor(Math.random() * maxPos));
		　　}
		　　return pwd;
		}
		function imgFilter(item,id) {
			console.log(item+'压缩前路径');
			//压缩图片
			var picname = randomString(32);
			var imageCachePath = api.cacheDir;
			var imageFilter = api.require('imageFilter');
			imageFilter.compress({
				img: item,
				quality : 1,
				scale : 1,
				save : {
					album : false,
					imgPath : imageCachePath,
					imgName : picname + '.jpg'
				}
			},function( ret, err ){        
				if( ret.status ){
					//$api.attr($api.byId('cardIDthumb'+id),'src',imageCachePath + '/' + picname + '.jpg');
					$api.byId('cardIDthumb'+id).src = imageCachePath + '/' + picname + '.jpg';
					if(!$api.hasCls($api.byId('cardIDthumb'+id).parentNode, 'on'))
					{
						$api.addCls($api.byId('cardIDthumb'+id).parentNode, 'on');
					}
					var picurl = $api.attr($api.byId('cardIDthumb'+id),'src');
					var trans = api.require('trans');
					trans.decodeImgToBase64({
						imgPath: picurl
					}, function(ret, err) {
						if (ret.status) {
							//转换成base64后上传
							var paramsObj = {
								base64str: 'data:image/jpeg;base64,'+ret.base64Str
							}
							uponeimg(paramsObj,'cardIDthumb_'+id);
						}
					});

				}else{
					alert( JSON.stringify( err ) );
				}
			});
		}
		function uponeimg(pObj,domid) {
			//上传单张图片
			api.showProgress({
				title: '请稍后...',
				text: '',
				modal: true
			});
			api.ajax({
				url: ApiUrl + '/v1/upimgs',
				method: 'post',
				cache: false,
				timeout: 10,
				headers: {
				},
				data: {
					values: pObj
				}
			}, function(ret, err) {
				api.hideProgress();
				if (ret) {
					$api.val($api.byId(domid),ret.picurl);
				}
			});
		}
		function checkCarnum() {
			//判断车牌号是否已参保
			var carnum = $api.val($api.byId('carnum')).trim();
			var paramsObj = {
				carnum: carnum
			};
			api.getPrefs({
				key: 'user_info'
			}, function(ret, err) {
				if (ret && ret.value)
				{
					var userinfo = JSON.parse(ret.value);
					api.ajax({
						url: ApiUrl + '/v1/insureextra',
						method: 'post',
						cache: false,
						timeout: 10,
						headers: {
							authorization: kAppKey+';'+userinfo.access_token+';'+userinfo.uid
						},
						data: {
							values: paramsObj
						}
					}, function(ret, err) {
						if (ret) {
							//var insureid = ret.insureid;
							if(ret.isxubao) {
								api.alert({
									title: '温馨提示',
									msg: '监测到本车还在保质期内，本次办理为续保！',
									buttons: ["我知道了"]
								}, function(ret, err) {
									if(ret.buttonIndex == 1)
									{
									}
								});
							}
							
						}
					});
				}
			});
		}
		
		function openAlert()
		{
			var icon = 'sucess.png';
			var title = '联保资料上传成功';
			var msg = '请等待系统审核';
			var winname = 'myinsuredetail_win';
			var btntxt = '返回';
			var param = {
				icon: icon,
				title: title,
				msg: msg,
				btntxt: btntxt,
				winname: winname,
			};
			openNavWin('#ddd','noheadmsg_win','../public/noheadmsg_frm.html','变更受益人',false,true,false,[],param);
		}
		function IdentityCodeValid(code) { 
			var city={11:"北京",12:"天津",13:"河北",14:"山西",15:"内蒙古",21:"辽宁",22:"吉林",23:"黑龙江 ",31:"上海",32:"江苏",33:"浙江",34:"安徽",35:"福建",36:"江西",37:"山东",41:"河南",42:"湖北 ",43:"湖南",44:"广东",45:"广西",46:"海南",50:"重庆",51:"四川",52:"贵州",53:"云南",54:"西藏 ",61:"陕西",62:"甘肃",63:"青海",64:"宁夏",65:"新疆",71:"台湾",81:"香港",82:"澳门",91:"国外 "};
            var tip = "";
            var pass= true;

            if(!code || !/^\d{6}(18|19|20)?\d{2}(0[1-9]|1[012])(0[1-9]|[12]\d|3[01])\d{3}(\d|X)$/i.test(code)){
                tip = "身份证号格式错误";
                pass = false;
            }

			else if(!city[code.substr(0,2)]){
                tip = "地址编码错误";
                pass = false;
            }
            else{
                //18位身份证需要验证最后一位校验位
                if(code.length == 18){
                    code = code.split('');
                    //∑(ai×Wi)(mod 11)
                    //加权因子
                    var factor = [ 7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2 ];
                    //校验位
                    var parity = [ 1, 0, 'X', 9, 8, 7, 6, 5, 4, 3, 2 ];
                    var sum = 0;
                    var ai = 0;
                    var wi = 0;
                    for (var i = 0; i < 17; i++)
                    {
                        ai = code[i];
                        wi = factor[i];
                        sum += ai * wi;
                    }
                    var last = parity[sum % 11];
                    if(parity[sum % 11] != code[17]){
                        tip = "校验位错误";
                        pass =false;
                    }
                }
            }
            //if(!pass) alert(tip);
            return pass;
        }
	</script>
</html>